﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="ADO.NET.Samples.Web._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
    <asp:GridView ID="GridViewArticles" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ArticleID" 
            DataSourceID="LinqDataSource1">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowSelectButton="True" />
            <asp:BoundField DataField="ArticleID" HeaderText="ArticleID" 
                InsertVisible="False" ReadOnly="True" SortExpression="ArticleID" />
            <asp:BoundField DataField="ArticleTitle" HeaderText="ArticleTitle" 
                SortExpression="ArticleTitle" />
            <asp:BoundField DataField="ArticleContent" HeaderText="ArticleContent" 
                SortExpression="ArticleContent" />
            <asp:BoundField DataField="UserID" HeaderText="UserID" 
                SortExpression="UserID" />
            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
                SortExpression="CategoryID" />
        </Columns>
        </asp:GridView>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
            ContextTypeName="ADO.NET.Samples.Web.ArticlesDataContext" EnableDelete="True" 
            EnableInsert="True" EnableUpdate="True" EntityTypeName="" 
            OrderBy="UserID desc, ArticleID" TableName="Articles">
        </asp:LinqDataSource>
    </p>
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="LinqDataSource2">
            <Columns>
                <asp:BoundField DataField="UserID" HeaderText="UserID" ReadOnly="True" 
                    SortExpression="UserID" />
                <asp:BoundField DataField="Count" HeaderText="Count" ReadOnly="True" 
                    SortExpression="Count" />
            </Columns>
        </asp:GridView>
        <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
            ContextTypeName="ADO.NET.Samples.Web.ArticlesDataContext" EntityTypeName="" 
            GroupBy="UserID" OrderGroupsBy="key" 
            Select="new (key as UserID, it as Articles, Count() as Count)" 
            TableName="Articles">
        </asp:LinqDataSource>
    </p>
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
        
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
</asp:Content>
